package cn.stylefeng.guns.modular.biz.controller;

import cn.stylefeng.guns.modular.biz.entity.OutWeightRecods;
import cn.stylefeng.guns.modular.biz.pojo.request.OutWeightRecodsRequest;
import cn.stylefeng.guns.modular.biz.service.OutWeightRecodsService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * 入炉煤分摊记录控制器
 *
 * @author 张朋飞
 * @since 2024/11/01 15:56
 */
@RestController
@ApiResource(name = "入炉煤分摊记录")
public class OutWeightRecodsController {

    @Resource
    private OutWeightRecodsService outWeightRecodsService;

    /**
     * 添加入炉煤分摊记录
     *
     * @author 张朋飞
     * @since 2024/11/01 15:56
     */
    @PostResource(name = "添加入炉煤分摊记录", path = "/outWeightRecods/add")
    public ResponseData<OutWeightRecods> add(@RequestBody @Validated(OutWeightRecodsRequest.add.class) OutWeightRecodsRequest outWeightRecodsRequest) {
        outWeightRecodsService.add(outWeightRecodsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 删除入炉煤分摊记录
     *
     * @author 张朋飞
     * @since 2024/11/01 15:56
     */
    @PostResource(name = "删除入炉煤分摊记录", path = "/outWeightRecods/delete")
    public ResponseData<?> delete(@RequestBody @Validated(OutWeightRecodsRequest.delete.class) OutWeightRecodsRequest outWeightRecodsRequest) {
        outWeightRecodsService.del(outWeightRecodsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 批量删除入炉煤分摊记录
     *
     * @author 张朋飞
     * @since 2024/11/01 15:56
     */
    @PostResource(name = "批量删除入炉煤分摊记录", path = "/outWeightRecods/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) OutWeightRecodsRequest outWeightRecodsRequest) {
        outWeightRecodsService.batchDelete(outWeightRecodsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑入炉煤分摊记录
     *
     * @author 张朋飞
     * @since 2024/11/01 15:56
     */
    @PostResource(name = "编辑入炉煤分摊记录", path = "/outWeightRecods/edit")
    public ResponseData<?> edit(@RequestBody @Validated(OutWeightRecodsRequest.edit.class) OutWeightRecodsRequest outWeightRecodsRequest) {
        outWeightRecodsService.edit(outWeightRecodsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 查看入炉煤分摊记录详情
     *
     * @author 张朋飞
     * @since 2024/11/01 15:56
     */
    @GetResource(name = "查看入炉煤分摊记录详情", path = "/outWeightRecods/detail")
    public ResponseData<OutWeightRecods> detail(@Validated(OutWeightRecodsRequest.detail.class) OutWeightRecodsRequest outWeightRecodsRequest) {
        return new SuccessResponseData<>(outWeightRecodsService.detail(outWeightRecodsRequest));
    }

    /**
     * 获取入炉煤分摊记录列表
     *
     * @author 张朋飞
     * @since 2024/11/01 15:56
     */
    @GetResource(name = "获取入炉煤分摊记录列表", path = "/outWeightRecods/list")
    public ResponseData<List<OutWeightRecods>> list(OutWeightRecodsRequest outWeightRecodsRequest) {
        return new SuccessResponseData<>(outWeightRecodsService.findList(outWeightRecodsRequest));
    }

    /**
     * 获取入炉煤分摊记录列表（带分页）
     *
     * @author 张朋飞
     * @since 2024/11/01 15:56
     */
    @GetResource(name = "获取入炉煤分摊记录列表（带分页）", path = "/outWeightRecods/page")
    public ResponseData<PageResult<OutWeightRecods>> page(OutWeightRecodsRequest outWeightRecodsRequest) {
        return new SuccessResponseData<>(outWeightRecodsService.findPage(outWeightRecodsRequest));
    }

}
